#include <iostream>
#include <stdio.h>

using namespace std;


int a[5000];
int main() {
    int n,k;
    cin >> n >> k;
    for(int i = 0 ; i< n; i++){
        cin >> a[i];
    }
    k--;
    int c,d;
    int sum = 0;
    c = a[k+1]-a[k];
    d = a[k-1]-a[k];
    int e = 0;
    int f = 0;
    for(int i = 1 ; i < n-k; i++){
        e = a[k] + i * c;
        if(e == a[k+i]){
            sum ++;
        }
        else if(e < a[k+i]){
            sum ++;
            c = a[i+k] - a[i+k-1];
        }
        cout << c << endl << e << endl;
    }
    for(int i = 1 ; i < k; i++){
        f = a[k] - i * d;
        if(f == a[k-i]){
            sum ++;
        }
        else if(f < a[k-i]){
            sum ++;
            d = a[k-i] - a[k-i+1]; 
        }
    }
    cout << sum;
    return 0;
}